package com.git.hui.yinshua.biz.goods.dao.mapper;

import com.git.hui.yinshua.biz.goods.dao.domain.GoodsDetailEntity;
import com.git.hui.yinshua.biz.goods.dao.domain.GoodsEntity;
import com.git.hui.yinshua.biz.goods.dao.domain.GoodsSpecEntity;
import com.git.hui.yinshua.biz.rest.models.goods.req.GoodsQueryReq;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.util.List;

/**
 * @author YiHui
 * @date 2024/6/12
 */
@Mapper
public interface GoodsMapper {
    Integer saveGoods(@Param("goods") GoodsEntity entity);

    Integer saveDetails(@Param("details") List<GoodsDetailEntity> list);

    Integer saveSpecs(@Param("specs") List<GoodsSpecEntity> list);


    /**
     * 商品更新
     *
     * @param entity
     * @return
     */
    Integer updateGoods(GoodsEntity entity);

    Integer updateDetails(@Param("details") List<GoodsDetailEntity> list);

    Integer updateSpecs(@Param("specs") List<GoodsSpecEntity> list);

    Integer deleteDetails(@Param("detailIds") List<Integer> detailIds);

    Integer deleteSpecs(@Param("specIds") List<Integer> specIds);

    Integer deleteGoods(@Param("goodsId") Integer goodsId);


    // ------------- 销量 & 库存更新 ----------------

    Integer addGoodsSalesCnt(@Param("goodsId") Integer goodsId);

    Integer addSpecSalesCnt(@Param("specId") Integer specId);


    // ------- 查询
    int queryGoodsState(@Param("id") Integer goodsId);

    GoodsEntity queryDetail(@Param("id") Integer goodsId);

    List<GoodsEntity> listSimpleGoods(GoodsQueryReq query);

    List<GoodsEntity> listGoods(GoodsQueryReq query);

    Integer goodsCount(GoodsQueryReq query);
}
